//
//  PhotoImageViewController.m
//  Flickr
//
//  Created by nhieu nguyen on 7/25/13.
//  Copyright (c) 2013 nhieu.nguyen. All rights reserved.
//

#import "PhotoImageViewController.h"

@interface PhotoImageViewController ()

@end

@implementation PhotoImageViewController

@synthesize scrollView = _scrollView;
@synthesize imageView = _imageView;
@synthesize imageUrl = _imageUrl;
@synthesize imageTitle  = _imageTitle;

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    if (self.imageTitle) {
        self.navigationItem.title = self.imageTitle;
    }
    NSData *imageData = [[NSData alloc] initWithContentsOfURL:self.imageUrl];
    UIImage *image = [UIImage imageWithData:imageData];
    
    self.scrollView.minimumZoomScale = 0.6;
    self.scrollView.maximumZoomScale = 2.0;
   // self.imageView = [[UIImageView alloc] init];
    [self.imageView setImage:image];
    [self.imageView setContentMode:UIViewContentModeScaleAspectFit];
   // [self.scrollView setContentMode:UIViewContentModeScaleAspectFill];
    self.scrollView.delegate = self;
   /* self.scrollView.contentSize = CGSizeMake(self.imageView.bounds.size.width, self.imageView.bounds.size.height);
    self.scrollView.decelerationRate = UIScrollViewDecelerationRateFast;*/
    
    _scrollView.zoomScale = 1.0;
    self.imageView.frame = CGRectMake(0, 0, self.imageView.image.size.width, self.imageView.image.size.height) ;
    NSLog(@"%@", self.imageUrl);
	// Do any additional setup after loading the view.
}

- (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView {
    return self.imageView;
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
